package com.jtbd.controller;

import com.jtbd.constants.ResponseCodeEnum;
import com.jtbd.dto.CampusCreateHttpDto;
import com.jtbd.dto.result.ResponseBaseData;
import com.jtbd.service.CampusManagementService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "校区管理接口")
@RequestMapping("/campus")
public class CampusManagementController {
    @Resource
    private CampusManagementService campusManagementService;

    @PostMapping("/addCampus")
    @Operation(summary = "添加校区")
    public ResponseBaseData<Long> addCampus(@Validated @RequestBody CampusCreateHttpDto campusCreateHttpDto) {
        long addResult = campusManagementService.addCampus(campusCreateHttpDto);
        if (addResult > 0) {
            return ResponseBaseData.success(campusCreateHttpDto.getCampus().getId());
        }
        return ResponseBaseData.error(ResponseCodeEnum.ERROR);
    }
}
